﻿using System.Text;
using Newtonsoft.Json;

namespace WPHttpServer
{
    public class JsonResponseContentProvider : IResponseContentProvider
    {
        public object JsonObject { get; set; }

        public JsonResponseContentProvider(object jsonObject)
        {
            JsonObject = jsonObject;
        }

        public string ContentMediaTypeName { get { return "text/json"; } }
        public byte[] GetContentData()
        {
            string jsonText = JsonConvert.SerializeObject(this.JsonObject);
            byte[] data = Encoding.UTF8.GetBytes(jsonText);
            return data;
        }
    }
}
